package com.nowcoder.code.lcof;

import java.util.BitSet;

public class JZ3 {

    public static void main(String[] args) {
        int[] is = {2, 3, 1, 0, 2, 5, 3};
        System.out.println(new JZ3().duplicate(is));
    }

    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     *
     * @param numbers int整型一维数组
     * @return int整型
     */
    public int duplicate(int[] numbers) {

        BitSet bitSet = new BitSet(numbers.length);

        for (int number : numbers) {
            if (bitSet.get(number)) {
                return number;
            }
            bitSet.set(number);
        }
        return -1;
    }

}
